package com.zsj.juc.lock;

import java.util.concurrent.CyclicBarrier;

/**
 * @author zsj
 * @version 1.0
 * @date 2024/4/21 16:36
 * @description
 */
public class CyclicBarrierDemo {
    public static void main(String[] args) {
        CyclicBarrier cyclicBarrier = new CyclicBarrier(7, () -> {
            System.out.println("你妈的 你成功了");
        });
        for (int i = 0; i < 7; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "干完了");
                try {
                    cyclicBarrier.await();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }, "" + i).start();
        }
    }
}
